package com.xiangb.springbootjpa.common;

import org.springframework.data.domain.Page;

import java.util.List;

/**
 * Description: <br>
 *
 * @author: XB
 * @date: 2020/12/22 11:13
 */
public class PageVO<T> {
    private int pageNumber;//当前页码
    private int pageSize;//每页条数
    private long total;//总条数
    private int totalPage;//总页数
    private List<T> result;//当前页列表

    public void pageToVO(Page<T> page) {
        this.pageNumber = page.getNumber();
        this.pageSize = page.getSize();
        this.totalPage = page.getTotalPages();
        this.total = page.getTotalElements();
        this.result = page.getContent();
    }

    public int getPageNumber() {
        return pageNumber;
    }

    public void setPageNumber(int pageNumber) {
        this.pageNumber = pageNumber;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public List<T> getResult() {
        return result;
    }

    public void setResult(List<T> result) {
        this.result = result;
    }
}
